import {
  Inject,
  Controller,
  Post,
  Get,
  Put,
  Del,
  Query,
  Body,
} from '@midwayjs/core';
import { ApiResponse, ApiQuery } from '@midwayjs/swagger';
import { Context } from '@midwayjs/koa';
import { BaseController } from './base';
import { BaseService } from '../service/base';
import { SuccessWrapper } from '../types/base';

@Controller('/api/v1/dept', {
  description: '部门相关接口',
  tagName: 'Dept模块',
})
export class DeptController extends BaseController {
  @Inject()
  ctx: Context;

  @Inject()
  service: BaseService;

  @Post('/add')
  add(@Body() body) {
    return this.service.add(body);
  }

  @Put('/update')
  update(@Body() body) {
    return this.service.update(body);
  }

  @Del('/delete')
  delete(@Body() body) {
    return this.service.delete(body);
  }

  @Get('/info')
  info(@Query() query) {
    return this.service.info(query);
  }

  @Get('/list')
  @ApiResponse({
    status: 200,
    description: 'The found record',
    type: SuccessWrapper,
  })
  @ApiQuery({
    name: 'current',
    description: 'The found record',
  })
  list(@Query() query) {
    return this.service.list(query);
  }
}
